package srx.open.com.activity;

import android.annotation.TargetApi;
import android.app.Activity;
import android.content.Intent;
import android.os.Build;
import android.os.Bundle;
import android.os.Handler;
import android.view.View;

import srx.open.com.R;

/**
 * 启动页面
 * @author hailongqiu 356752238@qq.com
 *
 */
public class SplashActivity extends Activity implements Runnable {

	private static final long DELAY_TIME = 666L;

	@Override
	protected void onCreate(Bundle savedInstanceState) {
		super.onCreate(savedInstanceState);
		setContentView(R.layout.activity_splash);
		initAllViews();
	}

	@TargetApi(Build.VERSION_CODES.HONEYCOMB)
	void initAllViews() {
		getWindow().getDecorView().setSystemUiVisibility(View.SYSTEM_UI_FLAG_HIDE_NAVIGATION);
		redirectByTime();
	}

	Handler jmpHandler = new Handler();

	private void redirectByTime() {
		jmpHandler.postDelayed(this, DELAY_TIME);
	}

	@Override
	protected void onDestroy() {
		super.onDestroy();
		jmpHandler.removeCallbacks(this);
	}
	
	@Override
	public void run() {
		finish();
		Intent intent = new Intent();
		intent.setClass(SplashActivity.this, HomeActivity.class);
		startActivity(intent);
	}

}
